package WaiBao;

import java.util.Arrays;

public class GuanYuShan {
    public static void main(String[] args) {
        String[] name = {"陈奕迅(班长)","张杰(体育委员)", "小李(学习委员)","张文凯(文艺委员)", "李大宝", "张晓明", "杨颖", "杨莹", "李大英", "李思远", "单车", "张大大",
                "王晓晓", "张小红", "李大光", "李军", "郑凯", "李潇潇", "李志豪", "姜维", "徐康", "徐朗", "姜维", "张继科", "徐敬业", "海文", "张德元", "李绍普",
                "肖战", "关雨珊(学生)"};//考生本人: 关雨珊(学生)
        int[] age = {21, 18, 19, 19, 18, 20, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 18, 20};//最后一位：考生年龄:20


        double[] youku1 = {84, 96, 76, 78, 77, 67, 78, 89, 81, 80, 91, 87, 85, 74, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 74, 88, 99};
        double[] youku2 = {84, 80, 95, 90, 68, 67, 69, 64, 88, 77, 90, 72, 76, 85, 65, 65, 76, 99, 66, 98, 72, 71, 95, 86, 75, 88, 84, 64, 80, 96};
        double[] youku3 = {89, 67, 84, 85, 75, 64, 78, 69, 80, 80, 83, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 95};



        double kaikai1;//代表每个学生的总分
        double kaikai2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            kaikai1 = youku1[i] + youku2[i] + youku3[i];
//            kaikai2= (kaikai1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + kaikai1);
//            System.out.println(name[i] + "的平均分为:" + kaikai2);
//        }



        double tebie1 = 0,tebie2 = 0;
        double[] gouhuo = new double[30];
//        for (int i = 0; i < 30; i++) {
//            tebie1= youku1[i] + youku2[i] + youku3[i];
//            tebie2 = (tebie1* 1.0) / 3;
//            gouhuo[i] = tebie2;
//        }
//
//        for (int i = 0; i < gouhuo.length - 1; i++) {
//            for (int j = 0; j < gouhuo.length - i - 1; j++) {
//                if (gouhuo [j] < gouhuo[j + 1]) {
//                    double tep = gouhuo[j];
//                    gouhuo[j] =gouhuo[j + 1];
//                    gouhuo [j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(gouhuo[i]);
//        }


        double qingchun1 = 0, qingchun2 = 0, qingchun3 = 0;//计算每门课的平均分
        double ziyu1 = 0, ziyu2 = 0, ziyu3 = 0;//计算每门课标准差
        double yingwei1 = 0,yingwei2 = 0, yingwei3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < youku1.length; i++) {
            he += youku1[i];
        }
        qingchun1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +qingchun1);
        double Sum = 0;
        for (int i = 0; i < youku2.length; i++) {
            Sum += youku2[i];
        }
        qingchun2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + qingchun2);
        double sum = 0;
        for (int i = 0; i < youku3.length; i++) {
            sum +=youku3[i];
        }
        qingchun3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + qingchun3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < youku1.length; i++) {
            c1 += (youku1[i] - qingchun1) * (youku1[i] -qingchun1);
        }
        ziyu1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + ziyu1);
        for (int i = 0; i <youku2.length; i++) {
            c2 += (youku2[i] - qingchun2) * (youku2[i] -qingchun2);
        }
        ziyu2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +ziyu2);

        for (int i = 0; i <youku3.length; i++) {
            c3 += (youku3[i] - qingchun3) * (youku3[i] - qingchun3);
        }
        ziyu3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" +ziyu3);
////
//        Arrays.sort(youku1);
//        Arrays.sort(youku2);
//        Arrays.sort(youku3);
//        yingwei1 = (youku1[15] + youku2[14]) * 1.0 / 2;
//        yingwei2 = (youku2[15] +youku2[14]) * 1.0 / 2;
//        yingwei3 = (youku3[15] + youku3[14]) * 1.0 / 2;
//        System.out.println("农业设施及环境调控的中位数为:" +  yingwei1);
//        System.out.println("农业设施设计与制造的中位数为:" +  yingwei2);
//        System.out.println("园艺植物设施栽培学的中位数为:" +  yingwei3);






    }
}
